package ru.susu.algebra.partition.polyhedron.checkers;

import java.math.BigInteger;
import java.util.List;

import ru.susu.algebra.partition.Partition;
import ru.susu.algebra.partition.polyhedron.VertexHelper;
import ru.susu.algebra.partition.vectex.Partition2VertexCache;

/**
 * @author akargapolov
 * @since: 09.03.2010
 */
public class ProductVertexChecker implements IVertexChecker
{
	/**
	 * {@inheritDoc}
	 */
	@Override
	public String check(Partition partition, List<Partition> allPartitions)
	{
		Integer[] array = Partition2VertexCache.getVertex(partition);
		BigInteger product = BigInteger.ONE;
		for (int index = 0;index<array.length;index++)
			if (array[index] > 0)
				product = product.multiply(BigInteger.valueOf(array[index] + 1));
		return (product.compareTo(BigInteger.valueOf(array.length + 1)) <= 0) ? CHECKED_RESULT :
			VertexHelper.getVertexString(partition) + " [" + product + " > " + (array.length + 1) + "]";
	}

}
